package com.ecoolex.hotel.saas.job.scheduler;

import com.ecoolex.framework.scheduler.Job;
import com.ecoolex.framework.scheduler.JobComponent;
import com.ecoolex.hotel.saas.core.manager.PresaleCouponManager;
import com.ecoolex.hotel.saas.entity.PresaleCoupon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@JobComponent
public class PresaleCouponCheckExpiredJob {

    private Logger log = LoggerFactory.getLogger(PresaleCouponCheckExpiredJob.class);

    @Autowired
    private PresaleCouponManager presaleCouponManager;

    @Job(name = "hotel.saas.PresaleCouponExpireCheckJob.checkExpire", describe = "检查过期预授券")
    public void process() {
        List<PresaleCoupon> list = presaleCouponManager.queryExpire(10);
        list.forEach(presaleCoupon -> {
            presaleCouponManager.offlinePresaleCoupon(presaleCoupon, PresaleCouponCheckExpiredJob.class.getSimpleName());
        });
    }
}
